using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InstanceManager : Singleton<InstanceManager>
{
    public void InstanceDivision(Vector3 trans, Vector3 size, string objPath, int count, float radio, float deltaTime)
    {
        StartCoroutine(Division(trans, size, objPath, count, radio, deltaTime));
    }

    public IEnumerator Division(Vector3 trans, Vector3 size, string objPath, int count, float radio, float deltaTime)
    {
        //TODO: 修复gameobject获取不到的问题
        var obj = Resources.Load(objPath) as GameObject;
        for (int i = 0; i < count; i++)
        {
            yield return new WaitForSeconds(deltaTime);
            var v = Random.insideUnitCircle;
            var a = GameObject.Instantiate(obj, trans + new Vector3(v.x, 0, v.y) * radio, Quaternion.identity);
            a.transform.localScale = size;
        }
    }
}
